<?php

namespace App\Notifications;

use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class ShipmentNotification extends Notification
{
    use Queueable;
	
	protected $message = '';
	
	/**
	 * @var Order|null
	 */
	protected $order = null;
	
	public function __construct($message, Model $order = null)
	{
		$this->message = $message;
		$this->order = $order;
	}
	
	public function via($notifiable)
	{
		return ['database'];
	}
	
	public function toDatabase($notification)
	{
		return [
			'message' => $this->message,
			'order' => $this->order->load('items.product')->unsetRelation('user')
		];
	}
}
